<?php
$menumark = 'moneycard';
switch ($act) {
    //#####################@ 修改分类 @#####################//
    case 'edit':
        include(pe_tpl('moneycard_edit.html'));
        break;

    case 'add':
        include(pe_tpl('moneycard_add.html'));
        break;

    case 'detail':
        $record = $db->pe_selectall('moneycard_record',array('record_type'=>1,'record_uid'=>$_g_id));
        include(pe_tpl('moneycard_detail.html'));
        break;

    case 'find':
        $sql = "select * from wxgg_moneycard where moneycard_number like '%{$_g_moneycard_number}%'";
        $moneycard = $db->sql_selectall($sql);
        include(pe_tpl('moneycard_list.html'));
        break;

    case 'charge':
        if(isGet()){
            include(pe_tpl('moneycard_charge.html'));
        }else{
            $moneycard = $db->pe_select('moneycard',array('moneycard_id'=>$_g_id));
            //计算总金额
            $money = $moneycard['moneycard_money'] + $_p_moneycard_money;
            //更新数据
            $db->pe_update('moneycard',array('moneycard_id'=>$_g_id),array('moneycard_money'=>$money));
            //插入数据
            $moneycard_record['record_type'] = 1;
            $moneycard_record['record_time'] = time();
            $moneycard_record['record_card_num'] = $moneycard['moneycard_number'];
            $moneycard_record['record_money'] = $_p_moneycard_money;
            $db->pe_insert('moneycard_record',$moneycard_record);
            pe_success('充值成功','admin.php?mod=moneycard');
        }

        break;

    case 'mo_cost_record':
        $record = $db->pe_selectall('moneycard_record',array('record_type'=>2,'record_uid'=>$_g_id));
        include(pe_tpl('mo_cost_record.html'));
        break;
    //#####################@ 分类列表 @#####################//
    default :
        $sql = 'select mo.moneycard_id,mo.moneycard_number,mo.moneycard_money,u.user_wxname from wxgg_moneycard as mo join wxgg_user as u on mo.moneycard_uid = u.user_id';
        $moneycard = $db->sql_selectall($sql);
        include(pe_tpl('moneycard_list.html'));

        break;
}
?>